Returns the lastlogin information for user and computer accounts from all DCs using the SamAccountName.
#Include <AD.au3>
_AD_GetLastLoginDate([$sObject = @Username[, $sSite = ""[, $aDCList = ""]]])
Parameters
| $sObject | Optional: SamAccountName of a user or computer account to get the last login date (default = @Username). |
| $sSite | Optional: Only query DCs that belong to this site(s) (default = all sites). This can be a single site or a list of sites separated by commas |
| $aDCList | Optional: one-based two dimensional array of Domain Controllers as returned by function _AD_ListDomainControllers (default = "") |
Return Value
Success: Last login date returned as YYYYMMDDHHMMSS. @extended is set to the total number of Domain Controllers.
Remarks
If it takes (too) long to get a result either some DCs are down or you have too many DCs in your AD.
Related
See Also
http://blogs.technet.com/b/askds/archive/2009/04/15/the-lastlogontimestamp-attribute-what-it-was-designed-for-and-how-it-works.aspx
Example
#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include <AD.au3>
; Open Connection to the Active Directory
_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)
; *****************************************************************************
; Example 1
; Get last login date for current user. Returned as YYYYMMDDHHMMSS
; *****************************************************************************
Global $iLLDate = _AD_GetLastLoginDate()
MsgBox(64, "Active Directory Functions - Example 1", "Last Login Date for User '" & @UserName & "'" & @CRLF & $iLLDate)
; *****************************************************************************
; Example 2
; Get last login date for current computer. Returned as YYYYMMDDHHMMSS
; *****************************************************************************
$iLLDate = _AD_GetLastLoginDate(@ComputerName & "$")
MsgBox(64, "Active Directory Functions - Example 2", "Last Login Date for Computer '" & @ComputerName & "$'" & @CRLF & $iLLDate)
; Close Connection to the Active Directory
_AD_Close()